package com.phoenix.jsef.common;

import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * @version V1.0
 * @ClassName: CacheEntity
 * @Description:TODO(用于缓存数据实体对象实体类)
 * @author: 李启联
 * @date: 2018-11-22 09:31
 * @Copyright: Copyright (c), 2018-2018
 * 申明：本内容未经作者本人同意,禁止外泄以及用于其他的商业项目.
 */
public class CacheEntity {
    /**
     * 缓存中保存的数据
     */
    private  Object datas;

    /**
     * 设置数据失效时间,为0表示永不失效
     */
    private  long timeOut = 0L;

    /**
     * 设置数据失效时间单位(如:小时,分钟,秒等)
     * 默认时间单位为分钟
     */
    private TimeUnit timeUnit = TimeUnit.MINUTES;

    /**
     * 最后刷新时间
     */
    private  long lastRefeshTime;

    /**
     * 定时器Future
     */
    public Future future;


    public Object getDatas() {
        return datas;
    }

    public void setDatas(Object datas) {
        this.datas = datas;
    }

    public long getTimeOut() {
        return timeOut;
    }

    public void setTimeOut(long timeOut) {
        this.timeOut = timeOut;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }

    public long getLastRefeshTime() {
        return lastRefeshTime;
    }

    public void setLastRefeshTime(long lastRefeshTime) {
        this.lastRefeshTime = lastRefeshTime;
    }

    public Future getFuture() {
        return future;
    }

    public void setFuture(Future future) {
        this.future = future;
    }

    //默认时间单位为分钟
    public CacheEntity(Object datas, long timeOut, long lastRefeshTime,Future future) {
        this.datas = datas;
        this.timeOut = timeOut;
        this.timeUnit = TimeUnit.MINUTES;
        this.lastRefeshTime = lastRefeshTime;
        this.future = future;
    }

    public CacheEntity(Object datas, long timeOut, TimeUnit timeUnit, long lastRefeshTime,Future future) {
        this.datas = datas;
        this.timeOut = timeOut;
        this.timeUnit = timeUnit;
        this.lastRefeshTime = lastRefeshTime;
        this.future = future;
    }

    public CacheEntity() {
    }

    @Override
    public String toString() {
        return "CacheEntity{" +
            "datas=" + datas +
            ", timeOut=" + timeOut +
            ", timeUnit=" + timeUnit +
            ", lastRefeshTime=" + lastRefeshTime +
            ", future=" + future +
            '}';
    }
}